package org.example.iterator;

import org.example.composite.Department;

import java.util.Iterator;
import java.util.List;

/**
 * @author wangbin
 * @date 2024/4/19
 * @vesion 1.0
 */
public class InfoComputerCollegeIterator implements Iterator {
    List<Department> dapartments;
    int index;

    public InfoComputerCollegeIterator(List<Department> dapartments) {
        this.dapartments = dapartments;
    }

    @Override
    public boolean hasNext() {

        if (index >= dapartments.size() - 1) {
            return false;
        }
        index += 1;
        return true;
    }

    @Override
    public Object next() {
        Department dapartment = dapartments.get(index);
        return dapartment;
    }

    @Override
    public void remove() {
        Iterator.super.remove();
    }
}
